package com.pat.jrgwt.client;

import com.google.gwt.core.client.GWT;
import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.uibinder.client.UiBinder;
import com.google.gwt.uibinder.client.UiField;
import com.google.gwt.uibinder.client.UiHandler;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.Button;
import com.google.gwt.user.client.ui.Composite;
import com.google.gwt.user.client.ui.Grid;
import com.google.gwt.user.client.ui.HasText;
import com.google.gwt.user.client.ui.Widget;

public class PipFactorValues extends Composite
{

    private static PipFactorValuesUiBinder uiBinder = GWT
            .create(PipFactorValuesUiBinder.class);
    @UiField Grid PipTable;

    interface PipFactorValuesUiBinder extends UiBinder<Widget, PipFactorValues>
    {
    }

    public PipFactorValues()
    {
        initWidget(uiBinder.createAndBindUi(this));

        PipTable.resize(10, 7);
        PipTable.setWidth("500px");
        PipTable.setHeight("300px");
        PipTable.setBorderWidth(1);
        PipTable.setCellSpacing(0);
        PipTable.setCellPadding(2);
        
        String[] arHeader = new String[]{ "2011", "EURUSD-30", "AUDJPY-120", "USDJPY-60", "USDJPY-120", "GBPJPY-60", "EURNZD-120" };

        // Format header
        for( int i = 0; i < PipTable.getColumnCount(); i++ )
        {
            PipTable.getCellFormatter().setWidth(0, i, "200");
            PipTable.getCellFormatter().setWordWrap(0, i, false);
            if( i < arHeader.length )
            {
                PipTable.setText(0, i, arHeader[i]);
            }
        }
        
        for( int i = 1; i < PipTable.getRowCount(); i++ )
        {
            PipTable.setText(i, 0, "" + i);
        }
        
        loadInitialData();
    }

    public PipFactorValues(String firstName)
    {
        initWidget(uiBinder.createAndBindUi(this));
    }
    
    protected void loadInitialData()
    {
        String[] arCell = new String[]{ "168.70", "-869.21", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0", "0.0" };
        
        String[] arCell2 = new String[] { "-1,242.87" , "-756.44" , "0.0" , "0.0" , "0.0" , "0.0" , "0.0" , "0.0" , "0.0" , "0.0" , "0.0" , "0.0" };
        
        String[] arCell3 = new String[] { "664.17" , "680.26" , "826.00" , "2,154.51" , "-1,561.89" , "-149.79" , "-655.78" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00"  };

        String[] arCell4 = new String[] { "0.00" , "0.00" , "1,391.97" , "2,669.83" , "-1,262.80" , "-359.49" , "664.82" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" };

        String[] arCell5 = new String[] { "-142.45" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" };

        String[] arCell6 = new String[] { "1,560.10" , "-128.64" , "288.42" , "2,770.04" , "1,485.54" , "910.69" , "2,205.98" , "0.00" , "0.00" , "0.00" , "0.00" , "0.00" };


        for( int i = 1; i < PipTable.getRowCount(); i++ )
        {
            PipTable.setText(i, 1, arCell[i - 1]);
            PipTable.setText(i, 2, arCell2[i - 1]);
            PipTable.setText(i, 3, arCell3[i - 1]);
            PipTable.setText(i, 4, arCell4[i - 1]);
            PipTable.setText(i, 5, arCell5[i - 1]);
            PipTable.setText(i, 6, arCell6[i - 1]);
        }

    }

}
